package com.ruoyi.web.controller.ora;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.ora.domain.UserWhite;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ora.domain.VoiceFolder;
import com.ruoyi.ora.service.IVoiceFolderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 语音文件夹Controller
 * 
 * @author liuwp
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/ora/voice_folder")
public class VoiceFolderController extends BaseController
{
    @Autowired
    private IVoiceFolderService voiceFolderService;

    /**
     * 查询语音文件夹列表
     */
    @PreAuthorize("@ss.hasPermi('ora:voice_folder:list')")
    @GetMapping("/list")
    public TableDataInfo list(VoiceFolder voiceFolder)
    {
        startPage();
        List<VoiceFolder> list = voiceFolderService.selectVoiceFolderList(voiceFolder);
        return getDataTable(list);
    }

    /**
     * 导出语音文件夹列表
     */
    @PreAuthorize("@ss.hasPermi('ora:voice_folder:export')")
    @Log(title = "语音文件夹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VoiceFolder voiceFolder)
    {
        List<VoiceFolder> list = voiceFolderService.selectVoiceFolderList(voiceFolder);
        ExcelUtil<VoiceFolder> util = new ExcelUtil<VoiceFolder>(VoiceFolder.class);
        util.exportExcel(response, list, "语音文件夹数据");
    }

    /**
     * 获取语音文件夹详细信息
     */
    @PreAuthorize("@ss.hasPermi('ora:voice_folder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(voiceFolderService.selectVoiceFolderById(id));
    }

    /**
     * 新增语音文件夹
     */
    @PreAuthorize("@ss.hasPermi('ora:voice_folder:add')")
    @Log(title = "语音文件夹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VoiceFolder voiceFolder)
    {
        return toAjax(voiceFolderService.insertVoiceFolder(voiceFolder));
    }

    /**
     * 修改语音文件夹
     */
    @PreAuthorize("@ss.hasPermi('ora:voice_folder:edit')")
    @Log(title = "语音文件夹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VoiceFolder voiceFolder)
    {
        return toAjax(voiceFolderService.updateVoiceFolder(voiceFolder));
    }

    /**
     * 删除语音文件夹
     */
    @PreAuthorize("@ss.hasPermi('ora:voice_folder:remove')")
    @Log(title = "语音文件夹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(voiceFolderService.deleteVoiceFolderByIds(ids));
    }


    @PreAuthorize("@ss.hasPermi('ora:voice_folder:list')")
    @GetMapping("/query")
    public AjaxResult query(VoiceFolder voiceFolder)
    {
        voiceFolder.setUserId(SecurityUtils.getUserId());
        List<VoiceFolder> list = voiceFolderService.selectVoiceFolderList(voiceFolder);
        return AjaxResult.success(list);
    }

    @PreAuthorize("@ss.hasPermi('ora:voice_folder:add')")
    @Log(title = "语音文件夹", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult addFolder(VoiceFolder voiceFolder)
    {
        voiceFolder.setUserId(SecurityUtils.getUserId());
        return toAjax(voiceFolderService.insertVoiceFolder(voiceFolder));
    }

}
